package com.kalman.webx;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.kalman.common.SafeConvert;

public class UserTrackInfo {

	private HttpServletRequest request;
	
	public UserTrackInfo(HttpServletRequest request){
		this.request = request;
	}
	/**获取HttpSession*/
	public HttpSession getHttpSession(){
		return request.getSession();
	}
	/**用户已经登录*/
	public boolean isLogin(){
		if(getHttpSession().getAttribute(SessionKeeper.LOGIN_USER) == null){
			return false;
		}
		return true;
	}
	
	public String getUserNick(){
		return SafeConvert.toString(getHttpSession().getAttribute(SessionKeeper.LOGIN_USER));
	}
	
	public long getUserDefinedId(){
		return SafeConvert.toLong(getHttpSession().getAttribute(SessionKeeper.LOGIN_USER_DEFINEDID), -1);
	}
	
	/**获取客户端请求的ip地址*/
	public String getIpAddress(){
		return IpAddress.getIpAddress(request);
	}
	
	public String getRequestPath(){
		return request.getRequestURL().toString();
	}
}